package view.component.window
{
import flash.errors.IllegalOperationError;
import flash.utils.Dictionary;

import framework.view.components.container.RepeaterProxy;

import view.component.window.event.NavigationChangeEvent;

/**
 * MutilpleClassifiedPaginationWindowProxy
 * @author jliang
 *
 */
public class MultipleClassifiedPaginationWindowProxy extends ClassifiedPaginationWindowProxy
{
    //==========================================================================
    //  Constructor
    //==========================================================================
    public function MultipleClassifiedPaginationWindowProxy()
    {
        super();
    }
    //==========================================================================
    //  Variables
    //==========================================================================	
    protected var SUB_TYPE_MAP:Dictionary = new Dictionary(true);
    
    protected var currentSubType:String;
    
    protected function get subNavRepeater():RepeaterProxy
    {
        return proxys["subNav"];
    }
    
    protected function get subNnavItemRenderClass():Class
    {
        throw new IllegalOperationError("subNavItemRenderClass getter should be overrided.");
    }
    
    protected function get currentSubTypeData():*		
    {
        return SUB_TYPE_MAP[currentSubType];
    }
    
    protected function get currentSubTypeDataLength():*		
    {
        throw new IllegalOperationError("currentTypeDataLength getter should be overrided.");
    }
    //==========================================================================
    //  Overridden methods: PaginationWindowProxy
    //==========================================================================
    override protected function get proxyMapping():Array
    {
        return [ 
            { skin:"subNav", classRef: RepeaterProxy, id:"subNav", renderProxyRef:subNnavItemRenderClass }
        ].concat(super.proxyMapping);
    }    
    
    override protected function clickToGoPrevHandler():void
    {
        updateList(currentSubTypeData, currentSubTypeDataLength, currentPage - 1);
    }
    
    override protected function clickToGoNextHandler():void
    {
        updateList(currentSubTypeData, currentSubTypeDataLength, currentPage + 1);
    }
    
    override protected function initEventListener():void		
    {		
        super.initEventListener();
        subNavRepeater.skinContent.addEventListener(NavigationChangeEvent.NAV_CHANGED, subNavigationChangeHandler);
    }
    
    override protected function clearEventListener():void		
    {		
        super.clearEventListener();
        subNavRepeater.skinContent.addEventListener(NavigationChangeEvent.NAV_CHANGED, subNavigationChangeHandler);
    }
    //==========================================================================
    //  Protected methods
    //==========================================================================
    protected function addSubTypeData(key:String, source:*):void
    {
        SUB_TYPE_MAP[key] = source;
    }
    //==========================================================================
    //  Event handlers
    //==========================================================================
    protected function subNavigationChangeHandler(event:NavigationChangeEvent):void
    {
        
    }
}
}




